<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>新增菜单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <div th:replace="comm/page::layui_css"/>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">任务名称</label>
                <div class="layui-input-block">
                    <input type="text" name="jobName"
                           th:disabled="${isEdit}"
                           placeholder="" autocomplete="off" class="layui-input"
                           th:value="${job?.jobName}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">类名称</label>
                <div class="layui-input-block">
                    <input type="text" name="jobClassName"
                           th:disabled="${isEdit}"
                           placeholder="" autocomplete="off" class="layui-input"
                           th:value="${job?.jobClassName}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">任务分组</label>
                <div class="layui-input-block">
                    <input type="text" name="jobGroup"
                           th:disabled="${isEdit}" placeholder="" autocomplete="off" class="layui-input"
                           th:value="${job?.jobGroup}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">表达式</label>
                <div class="layui-input-block">
                    <input type="text" name="cronExpression"
                           placeholder="" autocomplete="off" class="layui-input"
                           th:value="${job?.cronExpression}">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="jobEdit" lay-submit>确定</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div th:replace="comm/page::layui_script"/>
<script>
    var isEdit = [[${isEdit}]];
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        form.on('submit(jobEdit)', function (ret) {
            var data = ret.field;
            if (isEdit) {
                $.post("/job/cron", data, function (e) {
                    if (e.code === 0) {
                        layer.msg(e.msg);
                        // parent.layer.msg('您将标记 [ ' +val + ' ] 成功传送给了父窗口');
                        window.dialogJobEdit && window.layer.close(window.dialogJobEdit);
                        window.refreshView && window.refreshView();

                    } else {
                        layer.msg(e.msg);
                    }
                });
            } else {
                $.post("/job/add", data, function (e) {
                    if (e.code === 0) {
                        layer.msg(e.msg);
                        // parent.layer.msg('您将标记 [ ' +val + ' ] 成功传送给了父窗口');
                        window.dialogJobEdit && window.layer.close(window.dialogJobEdit);
                        window.refreshView && window.refreshView();

                    } else {
                        layer.msg(e.msg);
                    }
                });
            }
            return false;
        });
    });
</script>

</body>
</html>